home *** CD-ROM | disk | FTP | other *** search
- Path: nic.wat.hookup.net!news
- From: xenon@the-fix.sos.on.ca
- Newsgroups: comp.lang.c
- Subject: Re: Checking to See if a File Exists
- Date: Wed, 07 Feb 1996 02:05:54 GMT
- Organization: HookUp Communication Corporation, Waterloo, Ontario, CANADA
- Message-ID: <4f92ea$op9@nic.wat.hookup.net>
- References: <DLtI7G.HpE@midway.uchicago.edu> <3109a461.960289@ixnews1.ix.netcom.com>
- NNTP-Posting-Host: slip31.sos.on.ca
- X-Newsreader: Forte Free Agent 1.0.82
-
- n4jvp@ix.netcom.com (n4jvp) wrote:
-
- >On Sat, 27 Jan 1996 02:14:04 GMT, jaj3@kimbark.uchicago.edu (josef
- >jurek) wrote:
-
- >>
- >>How does one check from a C program to see whether a file
- >>exists or not?
- >>
- >>Thank you,
- >>
- >> --
- >>
- >>josef jurek
- >>jaj3@kimbark.uchicago.edu
- >>
-
- An easy way is too see what fopen is returning....
-
- #include <stdio.h>
-
- int main()
- {
- FILE *fp */pointer to file /*
-
- if((fp=fopen("filename.ext","r"))==NULL) */open the file, if it
- doesn't exist, fopen will return NULL/*
- {
- printf("Error: File not found");
-
- }
- else
- {
- printf("File succesfully opened!");
- }
- return 0; */can't forget that..../*
- }
-
-
-
-
-